<template>
<view class="common-text-publish-page">

  <u-field
      v-model="value"
      :label="label"
      :placeholder="placeholder"
      focus
  >
  </u-field>

  <view class="u-flex u-margin-top-80">
    <u-button @click="submit" type="error" size="medium">确定</u-button>
  </view>


</view>
</template>

<script>
export default {
  data(){
    return {
      // 输入的值
      value: '',
      // 标签名称
      label: '',
      // 输入提示
      placeholder: '',
      // 输入提醒
      tip: '',
      eventSuccessName: 'textPublishSuccess'
    }
  },
  onLoad(options){
    this.label = options.label || this.label
    this.placeholder = options.placeholder || this.placeholder
    this.tip = options.tip || this.tip
    this.eventSuccessName = options.eventSuccessName || this.eventSuccessName
  },
  methods: {
    submit(){
      if(!this.value){
        this.$u.toast((this.label || '内容') + '不能为空')
        return
      }
      uni.$emit(this.eventSuccessName,this.value)
      this.$u.route({
        type: 'back'
      })
    }
  }
}
</script>

<style scoped>

</style>